package com.itheima_04;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test01 {
    public static void main(String[] args) throws DocumentException, ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        SAXReader saxReader = new SAXReader();
        Document read = saxReader.read(new File("day18_demo\\src\\com\\itheima_04\\xmlTestt.xml"));
        Element rootElement = read.getRootElement();
        //Element presonElement = rootElement.element("preson");如果只有一个根便签,只用获得一个root
        Element classNameElemet = rootElement.element("className");
        String className = classNameElemet.getText();

        Element methodNameElement = rootElement.element("methodName");
        String methodName = methodNameElement.getText();

        //反射

        Class clazz = Class.forName(className);
        //创建对象
        Object o = clazz.newInstance();
        //获取方法
        Method method = clazz.getMethod(methodName);
        method.invoke(o);



    }
}
